package com.design.facade;

/**
 * @author leali
 * @title: EncryptFacade
 * @projectName design
 * @description: EncryptFacade：加密外观类，充当外观类
 * @date 2022/1/3 0:16
 */
public class EncryptFacade extends AbstractEncryptFacade {
    private final FileReader fileReader;
    /**
     * CipherMachine 原有的加密方式
     * 符合开闭原则？
     */
    private final NewCipherMachine cipherMachine;
    private final FileWriter fileWriter;

    public EncryptFacade(){
        fileReader=new FileReader();
        cipherMachine=new NewCipherMachine();
        fileWriter=new FileWriter();
    }

    /**
     * 调用其他对象的业务方法
     * @param fileNameSrc 源文件
     * @param fileNameDes 目标文件
     */
    @Override
    public void fileEncrypt(String fileNameSrc, String fileNameDes)
    {
        fileWriter.write(cipherMachine.encrypt(fileReader.read(fileNameSrc)), fileNameDes);
    }
}
